
package com.luck.emp.common;

import java.sql.Types;
import java.util.HashMap;
import java.util.Map;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.StoredProcedure;


public class SpWhOrderM extends StoredProcedure {
	private final static String STORE_PROCEDURE_NAME = "PKG_ORDER.P_ADD_WH_ORDER_M";
	
	/**
	 * 编译存储过程
	 * @param jdbcTemplate
	 */
	public SpWhOrderM(JdbcTemplate jdbcTemplate) {
		super(jdbcTemplate, STORE_PROCEDURE_NAME);
		declareParameter(new SqlOutParameter("PO_ORDER_CODE",Types.VARCHAR));
		declareParameter(new SqlParameter("PI_BILL_TYPE",Types.VARCHAR));
		//declareParameter(new SqlParameter("PI_URGENT",Types.INTEGER));
		declareParameter(new SqlParameter("PI_RECEIPT_NO",Types.VARCHAR));
		declareParameter(new SqlParameter("PI_WH_CODE",Types.VARCHAR));
		declareParameter(new SqlParameter("PI_VENDOR_CODE",Types.VARCHAR));
		declareParameter(new SqlParameter("PI_CONTACT",Types.VARCHAR));
		declareParameter(new SqlParameter("PI_TEL",Types.VARCHAR));
		declareParameter(new SqlParameter("PI_CONTACT_ADDR",Types.VARCHAR));
		//declareParameter(new SqlParameter("PI_ORDER_COST",Types.NUMERIC));
		declareParameter(new SqlParameter("PI_NOTE",Types.VARCHAR));
		declareParameter(new SqlParameter("PI_CREATE_USER",Types.INTEGER));
		declareParameter(new SqlParameter("PI_IO_TYPE",Types.VARCHAR));
		declareParameter(new SqlParameter("PI_CHANNEL_TYPE",Types.VARCHAR));
		declareParameter(new SqlParameter("PI_CUST_INFO_ID",Types.INTEGER));
		declareParameter(new SqlParameter("PI_SALEMAN_ID",Types.INTEGER));//业务员
		compile();
	}
	
	/**
	 * 执行存储过程
	 * @param deptCode
	 * @return
	 */
	public String execute(String billType, Long urgent, String receptNo, String whCode, String vendorCode, String contact, String tel, String addr, String note
			, Long createUserId, String ioType, String channelType, Long custId, Long salemanId){
		 Map params = new HashMap();
		 params.put("PI_BILL_TYPE", billType);
		 //params.put("PI_URGENT", urgent);
		 params.put("PI_RECEIPT_NO", receptNo);
		 params.put("PI_WH_CODE", whCode);
		 params.put("PI_VENDOR_CODE", vendorCode);
		 params.put("PI_CONTACT", contact);
		 params.put("PI_TEL", tel);
		 params.put("PI_CONTACT_ADDR", addr);
		 //params.put("PI_ORDER_COST", orderCost);
		 params.put("PI_NOTE", note);
		 params.put("PI_CREATE_USER", createUserId);
		 params.put("PI_IO_TYPE", ioType);
		 params.put("PI_CHANNEL_TYPE", channelType);
		 params.put("PI_CUST_INFO_ID", custId);
		 params.put("PI_SALEMAN_ID", salemanId);
		 Map result = super.execute(params);
		 return (String)result.get("PO_ORDER_CODE");
	 }
}
